package com.alipaytester.hanglv.controller;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

import com.alipaytester.hanglv.form.LoginForm;
import com.alipaytester.hanglv.impl.PersonDaoImpl;

@Controller
public class LoginController {
	@Autowired
	private PersonDaoImpl personDao;
	
	@RequestMapping(value = "/login.html")
	public ModelAndView doGet(HttpServletRequest request,
			HttpServletResponse response) {
		try {
				LoginForm loginForm = new LoginForm();
				loginForm.setUsername(request.getParameter("username"));
				loginForm.setNumber(request.getParameter("number"));
				personDao.add(loginForm);
		} catch (Exception e) {
			e.printStackTrace();
			return new ModelAndView("result/false");
		}
		return new ModelAndView("result/success");
	}

	public PersonDaoImpl getPersonDao() {
		return personDao;
	}

	public void setPersonDao(PersonDaoImpl personDao) {
		this.personDao = personDao;
	}
	
}
